<?xml version='1.0' encoding='iso-8859-1'?>

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:tn="http://tdwg.org/2006/03/12/TaxonNames/"

>

<xsl:output method='html' version='1.0' encoding='utf-8' indent='no'/>

    <xsl:template match="rdf:RDF">
    
    
    <html>
    <head>
    	<style type="text/css">
	body {
		font-family: Lucida Grande,Verdana,Arial,Helvetica, sans-serif;
		font-size: 11px;
		background-color: rgb(247,248,255);

	
	}
	tr {
		font-family: Lucida Grande,Verdana,Arial,Helvetica, sans-serif;
		font-size: 11px;
	}
	td.name { font-weight:bold; text-align: right; color:#555555;}
	td.value { font-weight:normal; text-align: left; color:#000000;}
	</style>
	</head>
	<body>

	<h3><xsl:value-of select="//@rdf:about" /></h3>
	<table border="0" cellpadding="1" cellspacing="1" width="100%">
	<xsl:apply-templates  />
	</table>

	</body>
	</html>
</xsl:template>

<xsl:template match="tn:TaxonName" >
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="rdf:Description" >
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="rdf:Property" >
<xsl:apply-templates select="*"/>
</xsl:template>

    <xsl:template name="hyperlink">
        <xsl:param name="string" select="string()"/>
        

        
        <xsl:choose>
            <xsl:when test="contains($string, 'http://')">
                <xsl:value-of select="substring-before($string, 'http://')"/>
                <xsl:variable name="rest" select="substring-after($string, 'http://')"/>
                <xsl:variable name="url" select="concat('http://', $rest)"/>
                <xsl:text></xsl:text>
                <a href="{$url}" target="_new">
                    <xsl:value-of select="$url"/>
                </a>
            </xsl:when>
            <!-- DOI -->
            <xsl:when test="contains($string, 'doi:')">
  
                <xsl:variable name="rest" select="substring-after($string, 'doi:')"/>
                <xsl:variable name="url" select="concat('http://dx.doi.org/', $rest)"/>
                <xsl:text> </xsl:text>
                <a href="{$url}" target="_new">
                    <xsl:text>CrossRef</xsl:text>
                </a>
            </xsl:when>


  

                <!-- PubMed -->
            <xsl:when test="contains($string, 'pmid:')">
                <xsl:variable name="rest" select="substring-after($string, 'pmid:')"/>
                <xsl:variable name="url" select="concat('http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&amp;db=PubMed&amp;list_uids=', $rest, '&amp;dopt=Abstract')"/>
                <xsl:text> </xsl:text>
                <a href="{$url}" target="_new">
                    <xsl:text>PubMed</xsl:text>
                    </a>
            </xsl:when>
                
                
                
                <!-- LSID -->
                
            <xsl:when test="contains($string, 'urn:lsid:')">
            	
            	<xsl:variable name="link" select="concat('/~rpage/lsid/tester/?q=', $string)" />
            	
            	<a href="{$link}" target="_parent">
            		<xsl:value-of select="$string" />
            	
            	</a>
            	
            </xsl:when>
            <xsl:otherwise>
                <!-- not an external link -->
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

<xsl:template match="*">
<tr valign="top">
<td class="name" valign="top">
<xsl:value-of select="local-name()" /><xsl:text>: </xsl:text><!--<img src="images/arrow.gif" />-->
</td>
<td class="value" >
                <xsl:value-of select="."/>
                <xsl:call-template name="hyperlink">
                    <xsl:with-param name="string" select="."/>
                </xsl:call-template>
                
                <!-- Display resource -->
                <xsl:if test = "@rdf:resource != ''">
					<xsl:call-template name="hyperlink">
						<xsl:with-param name="string" select="@rdf:resource" />
					</xsl:call-template>
                </xsl:if>

<!-- 
		<xsl:if test="local-name() = 'storedas' ">
					
<xsl:text>&#160;</xsl:text>
		<a>
			<xsl:attribute name="href"> -->
				<!-- Construct URL to data using paramater passed to the style sheet -->
<!--				<xsl:value-of select="."/><xsl:text>?lsid=</xsl:text><xsl:value-of select = "@rdf:resource" />
			</xsl:attribute >

			<xsl:attribute name="title">
				<xsl:text>This link points to URL of data for this LSID</xsl:text>
			</xsl:attribute >

			<xsl:text>Retrieve data</xsl:text>

		</a>

		</xsl:if> -->
</td>

</tr>


</xsl:template>



</xsl:stylesheet>